package com.nameless.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nameless.dao.RoleMapper;
import com.nameless.entity.Role;
import com.nameless.service.RoleService;
import com.nameless.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author : 陈灰灰
 * @Date: 2023/02/27/10:56
 * @Description:
 */
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {
    @Resource
    private RoleMapper roleMapper;
    @Override
    public List<Integer> findRolesByUserId(Integer userid) {
        List<Integer> roleIds = roleMapper.selectByUserId(userid);
        System.out.println(roleIds);
        return roleIds;
    }

    @Override
    public Result qr(Integer userid, Integer[] checkRole) {
        roleMapper.deleteByUserId(userid);
        int row = roleMapper.addUserRole(userid, checkRole);
        return new Result(200,"添加角色成功");
    }
}
